//输入一个长度大于10的整数数组,然后将它的各个元素逆序仍放入这个数组,
// 并且显示输出,同时将这个数组原始值和逆序后听结果输出写入文本文件中,
// 学号-f8.txt
#include <stdio.h>
#include <stdlib.h>

void descendorder(int nums[], int n)
{
    int i,tmp;
    for(i = 0; i < n/2; i++,n--)
    {
        tmp = nums[i];
        nums[i] = nums[n - 1];
        nums[n - 1] = tmp;
    }
}

int main(void)
{
    int nums[] = {1,2,1,3,6,8,4,5};
    int n = sizeof nums / sizeof nums[0];
    int i;
    FILE *fp;

    //int 类型数据输出到文本文件中
    fp = fopen("学号-f8.txt","w");
    if(fp == NULL)
    {
        fprintf(stderr,"学号-f8.txt open failed!");
        exit(1);
    }


    for(i = 0; i < n; i++)
    {
        fprintf(fp, "%d ",nums[i]);
    }
    fputc('\n', fp); 

    descendorder(nums, n);
    for(i = 0; i < n; i++)
    {
        fprintf(fp, "%d ",nums[i]);
    }
   
    fclose(fp);
    exit(0);
}